package com.zb.Service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.zb.Service.TaskService;
import com.zb.entity.Task;
import com.zb.mapper.TaskMapper;

@Component("TaskService")
public class TaskServiceImpl implements TaskService{
	
	@Resource
	private TaskMapper taskMapper;

	public List<Task> findTask(int index, int size, String min, String max,
			int tasktype,int senduser) {
		Map<String,Object> map=new HashMap<String ,Object>();
		if(min=="")
			min=null;
		if(max=="")
			max=null;
		map.put("index", (index-1)*size);
		map.put("size", size);
		map.put("min", min);	
		map.put("max", max);
		map.put("tasktype", tasktype);
		map.put("senduser", senduser);
		return taskMapper.findTask(map);
	}

	public int count() {
		return taskMapper.count();
	}

	public Task getTaskById(int id) {
		return taskMapper.getTaskById(id);
	}

	public int updateTask(Task task) {
		return taskMapper.updateTask(task);
	}

	public int savecaroTask(Task task) {
		return taskMapper.savecaroTask(task);
	}

	public List<Task> getDeskList(int uid) {
		return taskMapper.getDeskList(uid);
	}

	public void saveTask(int userid, int typeid, int contentid, int roleid) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("userid", userid);
		params.put("typeid", typeid);
		params.put("contentid", contentid);
		params.put("roleid", roleid);	
		taskMapper.saveTask(params);
		
	}

	public void updateTasktwo(Integer id, String ideal, Integer result) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ideal", ideal);
		params.put("id", id);
		params.put("result", result);
		taskMapper.updateTasktwo(params);
		
	}

	
	
}